package com.suxiaoxiao.springbootlearn.designpattern.commandpattern;

import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.ceilingfan.CeilingFan;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.ceilingfan.CeilingFanOffCommand;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.ceilingfan.CeilingFanHighCommand;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.garagedoor.GarageDoor;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.garagedoor.GarageDoorDownCommand;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.garagedoor.GarageDoorOpenCommand;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.light.Light;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.light.LightOffCommand;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.light.LightOnCommand;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.stereo.Stereo;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.stereo.StereoOffCommand;
import com.suxiaoxiao.springbootlearn.designpattern.commandpattern.commands.stereo.StereoOnWithCDCommand;

/**
 * 测试
 * @author 、
 */
public class RemoteLoader {

    public static void main(String[] args) {
        RemoteControl remoteControl = new RemoteControl();

        Light livingRoomLight = new Light("Living Room");
        Light kitchenLight = new Light("Kitchen");
        CeilingFan ceilingFan = new CeilingFan("Living Room");
        GarageDoor garageDoor = new GarageDoor("");
        Stereo stereo = new Stereo("Living Room");

        /**
         * 创建所有电灯命令对象
         */
        LightOnCommand livingRoomLightOn = new LightOnCommand(livingRoomLight);
        LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
        LightOnCommand kitchenLightOn = new LightOnCommand(kitchenLight);
        LightOffCommand kitchenLightOff = new LightOffCommand(kitchenLight);

        /**
         * 创建吊扇的开关命令
         */
        CeilingFanHighCommand ceilingFanOn = new CeilingFanHighCommand(ceilingFan);
        CeilingFanOffCommand ceilingFanOff = new CeilingFanOffCommand(ceilingFan);

        /**
         * 创建车库门的上与下命令
         */
        GarageDoorOpenCommand garageDoorOpen = new GarageDoorOpenCommand(garageDoor);
        GarageDoorDownCommand garageDoorDown = new GarageDoorDownCommand(garageDoor);

        /**
         * 创建音响的开与关命令
         */
        StereoOnWithCDCommand stereoOnWithCD = new StereoOnWithCDCommand(stereo);
        StereoOffCommand stereoOff = new StereoOffCommand(stereo);

        remoteControl.setCommand(0, livingRoomLightOn, livingRoomLightOff);
        remoteControl.setCommand(1, kitchenLightOn, kitchenLightOff);
        remoteControl.setCommand(2, ceilingFanOn, ceilingFanOff);
        remoteControl.setCommand(3, stereoOnWithCD, stereoOff);
        remoteControl.setCommand(4, garageDoorOpen, garageDoorDown);

        System.out.println(remoteControl);

        remoteControl.onButtonWasPushed(0);
        remoteControl.offButtonWasPushed(0);
        remoteControl.onButtonWasPushed(1);
        remoteControl.offButtonWasPushed(1);
        remoteControl.onButtonWasPushed(2);
        remoteControl.offButtonWasPushed(2);
        remoteControl.onButtonWasPushed(3);
        remoteControl.offButtonWasPushed(3);
        remoteControl.offButtonWasPushed(4);
        remoteControl.offButtonWasPushed(4);
    }

}
